#pragma once
#ifndef HIPPOWERKS_MATHLIB_H
#define HIPPOWERKS_MATHLIB_H
#include "engine.h"

namespace HW
{
flt Curve(flt newvalue, flt oldvalue, flt increments);
float Clamp(float value, float min=0.0f, float max=1.0f);
float PlaneDistanceToPoint(const TVec4& plane, const TVec3& point);

extern double Pi;

int sgn(float num);
int Min(int a, int b);
float Min(float a, float b);
double Min(double a, double b);
int Max(int a, int b);
float Max(float a, float b);
double Max(double a, double b);
double Log2(double n);
double deg2rad(double d);
double rad2deg(double r);
double RoundToInt(double num);
double Round(double num, int places=0);
const TVec2 operator+(const TVec2& lhs, const TVec2& rhs);
const TVec2 operator+(const TVec2& lhs, const flt rhs);
const TVec3 operator+(const TVec3& lhs, const TVec3& rhs);
const TVec3 operator+(const TVec3& lhs, const flt rhs);
const TVec4 operator+(const TVec4& lhs, const TVec4& rhs);
const TVec4 operator+(const TVec4& lhs, const flt rhs);
const TVec2& operator+=(TVec2& lhs, const TVec2& rhs);
const TVec2& operator+=(TVec2& lhs, const flt rhs);
const TVec3& operator+=(TVec3& lhs, const TVec3& rhs);
const TVec3& operator+=(TVec3& lhs, const flt rhs);
const TVec4& operator+=(TVec4& lhs, const TVec4& rhs);
const TVec4& operator+=(TVec4& lhs, const flt rhs);
const TVec2 operator-(const TVec2& lhs, const TVec2& rhs);
const TVec2 operator-(const TVec2& lhs, const flt rhs);
const TVec3 operator-(const TVec3& lhs, const TVec3& rhs);
const TVec3 operator-(const TVec3& lhs, const flt rhs);
const TVec4 operator-(const TVec4& lhs, const TVec4& rhs);
const TVec4 operator-(const TVec4& lhs, const flt rhs);
const TVec2& operator-=(TVec2& lhs, const TVec2& rhs);
const TVec2& operator-=(TVec2& lhs, const flt rhs);
const TVec3& operator-=(TVec3& lhs, const TVec3& rhs);
const TVec3& operator-=(TVec3& lhs, const flt rhs);
const TVec4& operator-=(TVec4& lhs, const TVec4& rhs);
const TVec4& operator-=(TVec4& lhs, const flt rhs);
const TVec2 operator*(const TVec2& lhs, const TVec2& rhs);
const TVec2 operator*(const TVec2& lhs, const flt rhs);
const TVec3 operator*(const TVec3& lhs, const TVec3& rhs);
const TVec3 operator*(const TVec3& lhs, const flt rhs);
const TVec4 operator*(const TVec4& lhs, const TVec4& rhs);
const TVec4 operator*(const TVec4& lhs, const flt rhs);
const TVec2& operator*=(TVec2& lhs, const TVec2& rhs);
const TVec2& operator*=(TVec2& lhs, const flt rhs);
const TVec3& operator*=(TVec3& lhs, const TVec3& rhs);
const TVec3& operator*=(TVec3& lhs, const flt rhs);
const TVec4& operator*=(TVec4& lhs, const TVec4& rhs);
const TVec4& operator*=(TVec4& lhs, const flt rhs);
const TVec2 operator/(const TVec2& lhs, const TVec2& rhs);
const TVec2 operator/(const TVec2& lhs, const flt rhs);
const TVec3 operator/(const TVec3& lhs, const TVec3& rhs);
const TVec3 operator/(const TVec3& lhs, const flt rhs);
const TVec4 operator/(const TVec4& lhs, const TVec4& rhs);
const TVec4 operator/(const TVec4& lhs, const flt rhs);
const TVec2& operator/=(TVec2& lhs, const TVec2& rhs);
const TVec2& operator/=(TVec2& lhs, const flt rhs);
const TVec3& operator/=(TVec3& lhs, const TVec3& rhs);
const TVec3& operator/=(TVec3& lhs, const flt rhs);
const TVec4& operator/=(TVec4& lhs, const TVec4& rhs);
const TVec4& operator/=(TVec4& lhs, const flt rhs);
const bool operator==(const TVec2& lhs, const TVec2& rhs);
const bool operator==(const TVec2& lhs, const flt rhs);
const bool operator==(const TVec3& lhs, const TVec3& rhs);
const bool operator==(const TVec3& lhs, const flt rhs);
const bool operator==(const TVec4& lhs, const TVec4& rhs);
const bool operator==(const TVec4& lhs, const flt rhs);
const bool operator!=(const TVec2& lhs, const TVec2& rhs);
const bool operator!=(const TVec2& lhs, const flt rhs);
const bool operator!=(const TVec3& lhs, const TVec3& rhs);
const bool operator!=(const TVec3& lhs, const flt rhs);
const bool operator!=(const TVec4& lhs, const TVec4& rhs);
const bool operator!=(const TVec4& lhs, const flt rhs);

const TVec4 operator*(const TVec16& lhs, const TVec4& rhs);

double Length(const TVec2& v);
double Length(const TVec3& v);
double Length(const TVec4& v);
const TVec2 Normalize(const TVec2& v);
const TVec3 Normalize(const TVec3& v);
const TVec4 Normalize(const TVec4& v);
double WrapAngle(double curangle);
double CurveAngle(double destinationAngle, double currentAngle, double steps);
double Lerp(double value1, double value2, double amount);
TVec4 Slerp(TVec4 qa, TVec4 qb, double t);
TVec3 QuatToEuler(TVec4 quat);
double Modulate(double a, double b);
double random(double min = 0.0, double max = 1.0);
double rnd(void);
void Randomize(void);

};
#endif // #ifndef HIPPOWERKS_MATHLIB_H
